package de.szut.ita13sommerfeld.blockadventure.window;

import de.szut.ita13sommerfeld.blockadventure.gameentities.Block;
import de.szut.ita13sommerfeld.blockadventure.gameentities.Entity;

public class GameCamera {

	private float x, y;
	private ViewArea viewarea;
	
	public GameCamera(float x, float y, ViewArea viewarea) {
		this.x = x;
		this.y = y;
		this.viewarea = viewarea;
	}
	
	public void tick(Entity player) {
		//stellt sicher, dass nur der sichbare Bereich geupdatet und gerendert wird
		if(player.getX() > Game.WIDTH / 2) {
			x = -player.getX() + Game.WIDTH / 2;
			viewarea.setMinimumX(player.getX() - Game.WIDTH / 2 - Block.WIDTH);
			viewarea.setMaximumX(player.getX() + Game.WIDTH / 2 + 5);
		} else {
			x = 0;
			viewarea.setMinimumX(0);
			viewarea.setMaximumX(Game.WIDTH);
		}
	}

	public float getX() {
		return x;
	}

	public float getY() {
		return y;
	}

	public void setX(float x) {
		this.x = x;
	}
	
	public void setY(float y) {
		this.y = y;
	}
	
	public ViewArea getViewArea() {
		return viewarea;
	}
	
	public void setViewArea(ViewArea viewarea)  {
		this.viewarea = viewarea;
	}
	
}
